﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.AspNetCore.Mvc.Controllers;
using Microsoft.AspNetCore.Mvc.Filters;
using Microsoft.AspNetCore.Routing;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace YSC_Backstage_Web.RestClient
{

    // 登录认证特性
    public class AuthenticationAttribute : ActionFilterAttribute
    {
        public override void OnActionExecuting(ActionExecutingContext context)
        {
            var item = context.HttpContext.Request.Query["X-TOKEN"];

            //拦截全局里是否带了token
            if (string.IsNullOrEmpty(context.HttpContext.Request.Query["X-TOKEN"]))
            {
                context.Result = new RedirectToRouteResult("Login", new RouteValueDictionary { { "Login", 1 } });
            }

        }
    }
}
